1. Technology Field
The present invention generally relates to a data writing method, and more particularly, to a data writing method for a non-volatile memory module and a memory controller and a memory storage apparatus using the same.
2. Description of Related Art
Along with the widespread of digital cameras, cell phones, and MP3 in recently years, the consumers' demand to digital storage media has increased drastically. Flash memory is one of the most adaptable storage media to be carried around and used for storing digital files due to its many characteristics such as data non-volatility, low power consumption, small volume, and non-mechanical structure.
Conventionally, a flash memory storage apparatus is usually used for storing user data. For example, a user uses a flash drive for storing digital files or uses a memory card as the storage medium of a portable device, such as a digital camera or a MP3 player. Such a flash memory storage apparatus is usually used for storing digital data in large quantities (for example, above 64 Kb or 128 Kb).
The storage capacity of flash memory storage apparatus has increased and the cost thereof has dropped along with the development of flash memory technology. Thus, many computer manufacturers start to use solid state drive (SSD) having flash memory as its storage medium as the master hard drive of computer system. The operating system of a computer system repeatedly writes and updates data of small quantities (for example, under 4 Kb or 8 Kb) in the master hard drive of the computer system.
Due to the physical characteristics of flash memories, each memory cell in a flash memory can only be programmed in a single direction (i.e., each bit in the memory cell can only be programmed from 1 to 0). Thus, data previously stored in a memory cell of a flash memory has to be erased before a new data can be written into the memory cell.
Regarding the design of flash memory storage system, the flash memory physical blocks in a flash memory storage system are usually grouped into a plurality of physical units (i.e., each physical unit is composed of one or more physical blocks). Each physical unit has at least one flash memory cell. Each memory cell is composed of at least one transistor (for example, MOSFET or other transistor or logic circuit) and can store at least one bit. Besides, the physical units are further grouped into a data area and a free area. The physical units in the data area are used for storing valid data written through write commands, and the physical units in the free area are used for substituting the physical units in the data area when the write commands are executed. To be specific, when a flash memory storage system receives a write command from a host and is about to write data into a physical unit in the data area, the flash memory storage system gets a physical unit from the free area and writes the old valid data in the physical unit to be written in the data area and the new data into the physical unit gotten from the free area, and the flash memory storage system associates the physical unit containing the new data with the data area, erases the physical unit in the data area, and associates it with the free area. In order to allow the host to successfully access the physical units that are alternatively used for storing data, the flash memory storage system configures logical units to be mapped to the physical units. To be specific, the flash memory storage system converts logical access addresses accessed by the host into corresponding logical units and records and updates the mapping relationship between the logical units and the physical units in the data area in a logical unit-physical unit mapping table so as to reflect the alternation of the physical units. Thus, the host simply accesses data according to the logical access addresses, while the flash memory storage system actually accesses data in the corresponding physical units according to the logical unit-physical unit mapping table.
Based on foregoing operation mechanism of flash memory storage system, when a flash memory storage system is used as a master hard drive of a computer system, because the computer system repeatedly writes and updates data of small quantities, the physical units in the flash memory storage system are frequently erased to be alternatively used for writing data from the computer system. Since each physical block in a physical unit can only be erased for a limited number of times (for example, a physical block is damaged after it is erased 10,000 times), the lifespan of the flash memory storage apparatus may be greatly shortened by frequently erasing the physical units thereof.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.